package com.shine.icis.hbean;

import java.io.Serializable;
import java.text.DecimalFormat;
import java.util.List;

import com.shine.icis.config.SysCodeDictLoader;

public class OfConfirmProc implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 3662405149335236166L;
	
	public static final String ARAP_TYPE_A0 = "A0";//法人实际交收金额
	public static final String ARAP_TYPE_A1 = "A1";//法人应交收金额
	public static final String ARAP_TYPE_02 = "02";//已收对方机构未付客户
	public static final String ARAP_TYPE_03 = "03";//已付客户未收对方机构
	private DecimalFormat doubleFormat = new DecimalFormat("0.00");
	
	private int id;
	private Integer orderDate;// 交易日期
	private Integer confirmDate;//确认日期
	private int settleDate;//交收日期
	private String arapType;// 应收应付类型
	private String oppPar;// 对方机构(这里都是TA代码)
    private String fundCode;//基金代码
	private String mktCode;// 市场代码
	private String arapBusiType;// 业务类型
	private String curType;// 币种
	private double arapAmt;// 金额
//	private String remark;// 备注
	private int busiDate;// 业务日期
	
	private transient List<OfConfirmProcDetail> details;
	
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public Integer getOrderDate() {
		return orderDate;
	}

	public void setOrderDate(Integer orderDate) {
		this.orderDate = orderDate;
	}

	public Integer getConfirmDate() {
		return confirmDate;
	}

	public void setConfirmDate(Integer confirmDate) {
		this.confirmDate = confirmDate;
	}

	public int getSettleDate() {
		return settleDate;
	}

	public void setSettleDate(int settleDate) {
		this.settleDate = settleDate;
	}

	public String getArapType() {
		return arapType;
	}

	public void setArapType(String arapType) {
		this.arapType = arapType;
	}

	public String getOppPar() {
		return oppPar;
	}

	public void setOppPar(String oppPar) {
		this.oppPar = oppPar;
	}

	public String getFundCode() {
		return fundCode;
	}

	public void setFundCode(String fundCode) {
		this.fundCode = fundCode;
	}
	
	public String getMktCode() {
		return mktCode;
	}

	public void setMktCode(String mktCode) {
		this.mktCode = mktCode;
	}

	public String getArapBusiType() {
		return arapBusiType;
	}

	public void setArapBusiType(String arapBusiType) {
		this.arapBusiType = arapBusiType;
	}

	public String getCurType() {
		return curType;
	}

	public void setCurType(String curType) {
		this.curType = curType;
	}

	public double getArapAmt() {
		return arapAmt;
	}

	public void setArapAmt(double arapAmt) {
		this.arapAmt = arapAmt;
	}

	public int getBusiDate() {
		return busiDate;
	}

	public void setBusiDate(int busiDate) {
		this.busiDate = busiDate;
	}
	
	public String getFormatOrderDate() {
		//20100909 -> 2010-09-09
		StringBuffer sb = new StringBuffer();
		sb.append(orderDate);
		if (sb.length() != 8) {
			return "";
		}
		return sb.insert(6, "-").insert(4, "-").toString();
	}
	public String getFormatConfirmDate() {
		//20100909 -> 2010-09-09
		StringBuffer sb = new StringBuffer();
		sb.append(confirmDate);
		if (sb.length() != 8) {
			return "";
		}
		return sb.insert(6, "-").insert(4, "-").toString();
	}
	public String getFormatSettleDate() {
		//20100909 -> 2010-09-09
		StringBuffer sb = new StringBuffer();
		sb.append(settleDate);
		if (sb.length() != 8) {
			return "";
		}
		return sb.insert(6, "-").insert(4, "-").toString();
	}
	
	public String getArapTypeText() {
		if ("00".equals(arapType)) {
			return "00:当日柜台入账（初始）";
		} else if ("99".equals(arapType)) {
			return "99:法人柜台都已交收入账";
		} else if ("A0".equals(arapType)) {
			return "A0:法人当日交收合计";
		} else {
			return arapType + ":" + SysCodeDictLoader.getInstance().getArapTypeConfText(arapType);
		}
	}
	
	
	public String getCurTypeText() {
		return curType + ":" + SysCodeDictLoader.getInstance().getCurTypeSipfConfText(curType);
	}
	
	public String getMktCodeText() {
		return mktCode + ":" + SysCodeDictLoader.getInstance().getMktCodeSipfConfText(mktCode);
	}
	
	public String getArapBusiTypeText() {
		return arapBusiType + ":" + SysCodeDictLoader.getInstance().getArapBusiTypeConfText(arapBusiType);
	}
	
	public String getArapAmtText() {
		return doubleFormat.format(arapAmt);
	}

	public List<OfConfirmProcDetail> getDetails() {
		return details;
	}

	public void setDetails(List<OfConfirmProcDetail> details) {
		this.details = details;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + id;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		final OfConfirmProc other = (OfConfirmProc) obj;
		if (id != other.id)
			return false;
		return true;
	}

}
